clear

cd C:\Users\dpage\Desktop\

set more off

use EJPR_REPLICATION_DATASET.dta, clear 


*Table 1

	*Persecuting States
			*vote
		proportion vote if HomosexualityJustifiable<5 & GBGR5point==1 
		proportion vote if HomosexualityJustifiable>5 & GBGR5point==1 
			*nonelectoral
		proportion PartDummy if HomosexualityJustifiable<5 & GBGR5point==1 
		proportion PartDummy if HomosexualityJustifiable>5 & GBGR5point==1 
			*age
		mean Age if HomosexualityJustifiable<5 & GBGR5point==1 
		mean Age if HomosexualityJustifiable>5 & GBGR5point==1 
			*women
		proportion Women if HomosexualityJustifiable<5 & GBGR5point==1 
		proportion Women if HomosexualityJustifiable>5 & GBGR5point==1 
			*income
		mean ScaleOfIncomes if HomosexualityJustifiable<5 & GBGR5point==1 
		mean ScaleOfIncomes if HomosexualityJustifiable>5 & GBGR5point==1 
			*married
		proportion Married if HomosexualityJustifiable<5 & GBGR5point==1 
		proportion Married if HomosexualityJustifiable>5 & GBGR5point==1 
			*religious person 
		proportion ReligiousPerson if HomosexualityJustifiable<5 & GBGR5point==1 
		proportion ReligiousPerson if HomosexualityJustifiable>5 & GBGR5point==1 
			*children
		mean HowManyChildren if HomosexualityJustifiable<5 & GBGR5point==1 
		mean HowManyChildren if HomosexualityJustifiable>5 & GBGR5point==1 
			*state ownership
		mean StateOwnershipSupport if HomosexualityJustifiable<5 & GBGR5point==1 
		mean StateOwnershipSupport if HomosexualityJustifiable>5 & GBGR5point==1 
			*postmaterialism
		mean PostMaterialist if HomosexualityJustifiable<5 & GBGR5point==1
		mean PostMaterialist if HomosexualityJustifiable>5 & GBGR5point==1
			*strong man 
		mean StrongLeaderAuthoritarian if HomosexualityJustifiable<5 & GBGR5point==1
		mean StrongLeaderAuthoritarian if HomosexualityJustifiable>5 & GBGR5point==1 
			*polity
		mean PolityScore if HomosexualityJustifiable<5 & GBGR5point==1 
		mean PolityScore if HomosexualityJustifiable>5 & GBGR5point==1 
			*gdppercapita
		mean GDPperCapita if HomosexualityJustifiable<5 & GBGR5point==1 
		mean GDPperCapita if HomosexualityJustifiable>5 & GBGR5point==1 
			*urban 	
		mean urbanpop if HomosexualityJustifiable<5 & GBGR5point==1 
		mean urbanpop if HomosexualityJustifiable>5 & GBGR5point==1 
			*Education level
		mean EducationLevel if HomosexualityJustifiable<5 & GBGR5point==1 
		mean EducationLevel if HomosexualityJustifiable>5 & GBGR5point==1 

	*Protecting States
			*vote
		proportion vote if HomosexualityJustifiable<5 & GBGR5point==5 
		proportion vote if HomosexualityJustifiable>5 & GBGR5point==5 
			*nonelectoral
		proportion PartDummy if HomosexualityJustifiable<5 & GBGR5point==5
		proportion PartDummy if HomosexualityJustifiable>5 & GBGR5point==5
			*age
		mean Age if HomosexualityJustifiable<5 & GBGR5point==5 
		mean Age if HomosexualityJustifiable>5 & GBGR5point==5 
			*women
		proportion Women if HomosexualityJustifiable<5 & GBGR5point==5 
		proportion Women if HomosexualityJustifiable>5 & GBGR5point==5 
			*income
		mean ScaleOfIncomes if HomosexualityJustifiable<5 & GBGR5point==5 
		mean ScaleOfIncomes if HomosexualityJustifiable>5 & GBGR5point==5 
			*married
		proportion Married if HomosexualityJustifiable<5 & GBGR5point==5 
		proportion Married if HomosexualityJustifiable>5 & GBGR5point==5 
			*religious person
		proportion ReligiousPerson if HomosexualityJustifiable<5 & GBGR5point==5 
		proportion ReligiousPerson if HomosexualityJustifiable>5 & GBGR5point==5 
			*children
		mean HowManyChildren if HomosexualityJustifiable<5 & GBGR5point==5 
		mean HowManyChildren if HomosexualityJustifiable>5 & GBGR5point==5
			*state ownership
		mean StateOwnershipSupport if HomosexualityJustifiable<5 & GBGR5point==5 
		mean StateOwnershipSupport if HomosexualityJustifiable>5 & GBGR5point==5 
			*postmaterialism
		mean PostMaterialist if HomosexualityJustifiable<5 & GBGR5point==5 
		mean PostMaterialist if HomosexualityJustifiable>5 & GBGR5point==5 
			*strong man 
		mean StrongLeaderAuthoritarian if HomosexualityJustifiable<5 & GBGR5point==5
		mean StrongLeaderAuthoritarian if HomosexualityJustifiable>5 & GBGR5point==5 
			*polity
		mean PolityScore if HomosexualityJustifiable<5 & GBGR5point==5 
		mean PolityScore if HomosexualityJustifiable>5 & GBGR5point==5 
			*gdppercapita
		mean GDPperCapita if HomosexualityJustifiable<5 & GBGR5point==5 
		mean GDPperCapita if HomosexualityJustifiable>5 & GBGR5point==5 
			*urban 	
		mean urbanpop if HomosexualityJustifiable<5 & GBGR5point==5 
		mean urbanpop if HomosexualityJustifiable>5 & GBGR5point==5 
			*Education level
		mean EducationLevel if HomosexualityJustifiable<5 & GBGR5point==5 
		mean EducationLevel if HomosexualityJustifiable>5 & GBGR5point==5 



*Table 2

		#delimit ;
		melogit vote GBGRscore HomosexualityJustifiable  
		Age Women EducationLevel ScaleOfIncomes Married ReligiousPerson HowManyChildren StateOwnershipSupport PostMaterialist StrongLeaderAuthoritarian
		PolityScore GDPperCapita urbanpop wave ||countrywave:
		;
		#delimit cr
		
		#delimit ;
		melogit vote GBGRscore HomosexualityJustifiable freeGBGR 
		Age Women EducationLevel ScaleOfIncomes Married ReligiousPerson HowManyChildren StateOwnershipSupport PostMaterialist StrongLeaderAuthoritarian
		PolityScore GDPperCapita urbanpop wave ||countrywave:
		;
		#delimit cr

		#delimit ;
		melogit PartDummy GBGRscore HomosexualityJustifiable  
		Age Women EducationLevel ScaleOfIncomes Married ReligiousPerson HowManyChildren StateOwnershipSupport PostMaterialist StrongLeaderAuthoritarian
		PolityScore GDPperCapita urbanpop wave ||countrywave:
		;
		#delimit cr
		
		#delimit ;
		melogit PartDummy GBGRscore HomosexualityJustifiable freeGBGR 
		Age Women EducationLevel ScaleOfIncomes Married ReligiousPerson HowManyChildren StateOwnershipSupport PostMaterialist StrongLeaderAuthoritarian
		PolityScore GDPperCapita urbanpop wave ||countrywave:
		;
		#delimit cr

		
*Figure 1
**********************************************************************************************************************************************
**********************************************************************************************************************************************	
		
		
clear
program drop _all

set more off

use EJPR_REPLICATION_DATASET.dta, clear 


#delimit ;
melogit vote GBGRscore HomosexualityJustifiable freeGBGR 
Age Women EducationLevel ScaleOfIncomes Married ReligiousPerson HowManyChildren StateOwnershipSupport PostMaterialist StrongLeaderAuthoritarian
PolityScore GDPperCapita urbanpop wave ||countrywave:
;
#delimit cr


set more off 
			 
		sum GDPperCapita 
			gen GDP_mean = r(mean) 
			
		sum PolityScore 
			gen Polity_mean = r(mean) 
		
		sum urbanpop 
			gen URBAN_mean = r(mean)
		
		sum EducationLevel 
			gen ED_mean = r(mean) 
		
		sum Age 
			gen Age_mean = r(mean)
			
		sum ScaleOfIncomes 
			gen INC_mean = r(mean)
		
		sum HowManyChildren 
			gen CHILD_mean = r(mean)
		
		sum StateOwnershipSupport 
			gen STATE_mean = r(mean)
		
		sum PostMaterialist
		    gen POST_mean = r(mean)
		
		sum StrongLeaderAuthoritarian
			gen AUTH_mean = r(mean)
			
	set more off 
	
		keep if _n==1 
		keep Age_mean Polity_mean GDP_mean ED_mean URBAN_mean INC_mean CHILD_mean STATE_mean POST_mean AUTH_mean
		 
		matrix def b = e(b)
		matrix def V = e(V)
		mat list b
		mat list V
		
		set more off
		save ParticipationProgramIVs.dta, replace
		
		*program drop ParticipationProgram2
	program define ParticipationProgram2
	use ParticipationProgramIVs.dta, clear
	
	drawnorm b1-b19, means(b) cov(V)
		

		#delimit ;
		gen pParticipation15d = b1*70 + b2*1 + b3*70*1 +
		b4*Age_mean + b5*1 + b6*ED_mean + b7*INC_mean + b8*1 + b9*1 +
		b10*CHILD_mean + b11*STATE_mean + b12*POST_mean + b13*AUTH_mean + b14*Polity_mean + b15*GDP_mean + b16*URBAN_mean + b17*1 + b18
		;
		#delimit cr

		#delimit ;
		gen pParticipation15nd = b1*70 + b2*5 + b3*70*5 +
		b4*Age_mean + b5*1 + b6*ED_mean + b7*INC_mean + b8*1 + b9*1 +
		b10*CHILD_mean + b11*STATE_mean + b12*POST_mean + b13*AUTH_mean + b14*Polity_mean + b15*GDP_mean + b16*URBAN_mean + b17*1 + b18
		;
		#delimit cr
	
		#delimit ;
		gen pParticipationEd = b1*33 + b2*1 + b3*33*1 +
		b4*Age_mean + b5*1 + b6*ED_mean + b7*INC_mean + b8*1 + b9*1 +
		b10*CHILD_mean + b11*STATE_mean + b12*POST_mean + b13*AUTH_mean + b14*Polity_mean + b15*GDP_mean + b16*URBAN_mean + b17*1 + b18
		;
		#delimit cr

		#delimit ;
		gen pParticipationEnd = b1*33 + b2*5 + b3*33*5 +
		b4*Age_mean + b5*1 + b6*ED_mean + b7*INC_mean + b8*1 + b9*1 +
		b10*CHILD_mean + b11*STATE_mean + b12*POST_mean + b13*AUTH_mean + b14*Polity_mean + b15*GDP_mean + b16*URBAN_mean + b17*1 + b18
		;
		#delimit cr

		
		
		
		gen Participation15d = exp(pParticipation15d)/(1+exp(pParticipation15d)) 
		gen Participation15nd = exp(pParticipation15nd)/(1+exp(pParticipation15nd)) 
		gen ParticipationEd = exp(pParticipationEd)/(1+exp(pParticipationEd)) 
		gen ParticipationEnd = exp(pParticipationEnd)/(1+exp(pParticipationEnd)) 
		

		
		
		gen DiffHomophobicState = ParticipationEd - ParticipationEnd
		gen DiffTolerantState = Participation15d - Participation15nd
	

		append using ParticipationPrograms2.dta
			save ParticipationPrograms2.dta, replace
			
			end
							
			clear
			save ParticipationPrograms2.dta, replace emptyok
	
			set more off
			simulate, reps(1500):  ParticipationProgram2

			use ParticipationPrograms2.dta, clear

			
						set more off			
#delimit ; 
collapse (mean) 
Participation15d Participation15nd ParticipationEd ParticipationEnd DiffHomophobicState DiffTolerantState

 (sd)
 Participation15d_sd=Participation15d Participation15nd_sd=Participation15nd 
 ParticipationEd_sd=ParticipationEd ParticipationEnd_sd=ParticipationEnd
 DiffHomophobicState_sd=DiffHomophobicState  DiffTolerantState_sd=DiffTolerantState
 
 
 ;
#delimit cr 	


gen Participation15d_hi = Participation15d + 1.96*Participation15d_sd
gen Participation15d_lo = Participation15d - 1.96*Participation15d_sd

gen Participation15nd_hi = Participation15nd + 1.96*Participation15nd_sd
gen Participation15nd_lo = Participation15nd - 1.96*Participation15nd_sd

gen ParticipationEd_hi = ParticipationEd + 1.96*ParticipationEd_sd
gen ParticipationEd_lo = ParticipationEd - 1.96*ParticipationEd_sd

gen ParticipationEnd_hi = ParticipationEnd + 1.96*ParticipationEnd_sd
gen ParticipationEnd_lo = ParticipationEnd - 1.96*ParticipationEnd_sd 

gen DiffHomophobicState_hi = DiffHomophobicState + 1.96*DiffHomophobicState_sd
gen DiffHomophobicState_lo = DiffHomophobicState - 1.96*DiffHomophobicState_sd

gen DiffTolerantState_hi = DiffTolerantState + 1.96*DiffTolerantState_sd
gen DiffTolerantState_lo = DiffTolerantState - 1.96*DiffTolerantState_sd




browse

gen axis_1 = 1
gen axis_2 = 2
gen axis_3 = 3
gen axis_4 = 4

lab def afmtlf2 1 "Homophobic" 2 "Tolerant" 3 "Homophobic" 4 "Tolerant" 
label val axis_1 afmtlf2 

#delimit ;
twoway (bar Participation15d axis_1, 
			color(black) barwidth(.5))
		(rcap Participation15d_lo Participation15d_hi axis_1,
			lcolor(gs10))
		(bar Participation15nd axis_2, 
			color(black) barwidth(.5))
		(rcap Participation15nd_lo Participation15nd_hi axis_2,
			lcolor(gs10))
		(bar ParticipationEd axis_3 , 
			color(gs10) barwidth(.5))
		(rcap ParticipationEd_lo ParticipationEd_hi axis_3,
			lcolor(black))
		(bar ParticipationEnd axis_4, 
			color(gs10) barwidth(.5))
		(rcap ParticipationEnd_lo ParticipationEnd_hi axis_4,
			lcolor(black)),
legend(off)
ylabel(.4(.1) .9)
title("Voting Model")
ytitle("Pr(Voted)", size(medsmall))
xlabel(#3,valuelabel angle(horizontal))
name(GPH1, replace)
scheme(s1mono);
#delimit cr	


	    #delimit ;
		twoway (bar DiffTolerantState axis_1, color(black)) (rcap DiffTolerantState_hi DiffTolerantState_lo axis_1, color(gs10)) 
		(bar DiffHomophobicState axis_2, color(gs10)) (rcap DiffHomophobicState_hi DiffHomophobicState_lo axis_2, color(black)), 
		scheme(s1mono) ylabel(.05(.05) -.10) ytitle("Difference in Pr(Voted)", size(medsmall))
		yline(0)
		xlabel( 1 "Protecting" 2 "Persecuting", noticks) 
		name(GPH2, replace)  
		 legend(off)
		;
		#delimit cr
		

		
		
		
clear
program drop _all

use EJPR_REPLICATION_DATASET.dta, clear 




#delimit ;
melogit PartDummy GBGRscore HomosexualityJustifiable freeGBGR 
Age Women EducationLevel ScaleOfIncomes Married ReligiousPerson HowManyChildren StateOwnershipSupport PostMaterialist StrongLeaderAuthoritarian
PolityScore GDPperCapita urbanpop wave ||countrywave:
;
#delimit cr


set more off 
			 
		sum GDPperCapita 
			gen GDP_mean = r(mean) 
			
		sum PolityScore 
			gen Polity_mean = r(mean) 
		
		sum urbanpop 
			gen URBAN_mean = r(mean)
		
		sum EducationLevel 
			gen ED_mean = r(mean) 
		
		sum Age 
			gen Age_mean = r(mean)
			
		sum ScaleOfIncomes 
			gen INC_mean = r(mean)
		
		sum HowManyChildren 
			gen CHILD_mean = r(mean)
		
		sum StateOwnershipSupport 
			gen STATE_mean = r(mean)
		
		sum PostMaterialist
		    gen POST_mean = r(mean)
		
		sum StrongLeaderAuthoritarian
			gen AUTH_mean = r(mean)
			

	set more off 
	
		keep if _n==1 
		keep Age_mean Polity_mean GDP_mean ED_mean URBAN_mean INC_mean CHILD_mean STATE_mean POST_mean AUTH_mean
		 
		matrix def b = e(b)
		matrix def V = e(V)
		mat list b
		mat list V
		
		set more off
		save ParticipationProgramIVs.dta, replace
		
		*program drop ParticipationProgram2
	program define ParticipationProgram2
	use ParticipationProgramIVs.dta, clear
	
	drawnorm b1-b19, means(b) cov(V)
		

		#delimit ;
		gen pParticipation15d = b1*70 + b2*1 + b3*70*1 +
		b4*Age_mean + b5*1 + b6*ED_mean + b7*INC_mean + b8*1 + b9*1 +
		b10*CHILD_mean + b11*STATE_mean + b12*POST_mean + b13*AUTH_mean + b14*Polity_mean + b15*GDP_mean + b16*URBAN_mean + b17*1 + b18
		;
		#delimit cr

		#delimit ;
		gen pParticipation15nd = b1*70 + b2*5 + b3*70*5 +
		b4*Age_mean + b5*1 + b6*ED_mean + b7*INC_mean + b8*1 + b9*1 +
		b10*CHILD_mean + b11*STATE_mean + b12*POST_mean + b13*AUTH_mean + b14*Polity_mean + b15*GDP_mean + b16*URBAN_mean + b17*1 + b18
		;
		#delimit cr

		#delimit ;
		gen pParticipationEd = b1*33 + b2*1 + b3*33*1 +
		b4*Age_mean + b5*1 + b6*ED_mean + b7*INC_mean + b8*1 + b9*1 +
		b10*CHILD_mean + b11*STATE_mean + b12*POST_mean + b13*AUTH_mean + b14*Polity_mean + b15*GDP_mean + b16*URBAN_mean + b17*1 + b18
		;
		#delimit cr

		#delimit ;
		gen pParticipationEnd = b1*33 + b2*5 + b3*33*5 +
		b4*Age_mean + b5*1 + b6*ED_mean + b7*INC_mean + b8*1 + b9*1 +
		b10*CHILD_mean + b11*STATE_mean + b12*POST_mean + b13*AUTH_mean + b14*Polity_mean + b15*GDP_mean + b16*URBAN_mean + b17*1 + b18
		;
		#delimit cr

		
		
		
		gen Participation15d = exp(pParticipation15d)/(1+exp(pParticipation15d)) 
		gen Participation15nd = exp(pParticipation15nd)/(1+exp(pParticipation15nd)) 
		gen ParticipationEd = exp(pParticipationEd)/(1+exp(pParticipationEd)) 
		gen ParticipationEnd = exp(pParticipationEnd)/(1+exp(pParticipationEnd)) 
		
		
		gen DiffHomophobicState = ParticipationEd - ParticipationEnd
		gen DiffTolerantState = Participation15d - Participation15nd
	

		append using ParticipationPrograms2.dta
			save ParticipationPrograms2.dta, replace
			
			end
							
			clear
			save ParticipationPrograms2.dta, replace emptyok
	
			set more off
			simulate, reps(1500):  ParticipationProgram2

			use ParticipationPrograms2.dta, clear

			
						set more off			
#delimit ; 
collapse (mean) 
Participation15d Participation15nd ParticipationEd ParticipationEnd DiffHomophobicState DiffTolerantState

 (sd)
 Participation15d_sd=Participation15d Participation15nd_sd=Participation15nd 
 ParticipationEd_sd=ParticipationEd ParticipationEnd_sd=ParticipationEnd
 DiffHomophobicState_sd=DiffHomophobicState  DiffTolerantState_sd=DiffTolerantState
 
 
 ;
#delimit cr 	


gen Participation15d_hi = Participation15d + 1.96*Participation15d_sd
gen Participation15d_lo = Participation15d - 1.96*Participation15d_sd

gen Participation15nd_hi = Participation15nd + 1.96*Participation15nd_sd
gen Participation15nd_lo = Participation15nd - 1.96*Participation15nd_sd

gen ParticipationEd_hi = ParticipationEd + 1.96*ParticipationEd_sd
gen ParticipationEd_lo = ParticipationEd - 1.96*ParticipationEd_sd

gen ParticipationEnd_hi = ParticipationEnd + 1.96*ParticipationEnd_sd
gen ParticipationEnd_lo = ParticipationEnd - 1.96*ParticipationEnd_sd 

gen DiffHomophobicState_hi = DiffHomophobicState + 1.96*DiffHomophobicState_sd
gen DiffHomophobicState_lo = DiffHomophobicState - 1.96*DiffHomophobicState_sd

gen DiffTolerantState_hi = DiffTolerantState + 1.96*DiffTolerantState_sd
gen DiffTolerantState_lo = DiffTolerantState - 1.96*DiffTolerantState_sd




browse

gen axis_1 = 1
gen axis_2 = 2
gen axis_3 = 3
gen axis_4 = 4

lab def afmtlf2 1 "Homophobic" 2 "Tolerant" 3 "Homophobic" 4 "Tolerant" 
label val axis_1 afmtlf2 

#delimit ;
twoway (bar Participation15d axis_1, 
			color(black) barwidth(.5))
		(rcap Participation15d_lo Participation15d_hi axis_1,
			lcolor(gs10))
		(bar Participation15nd axis_2, 
			color(black) barwidth(.5))
		(rcap Participation15nd_lo Participation15nd_hi axis_2,
			lcolor(gs10))
		(bar ParticipationEd axis_3 , 
			color(gs10) barwidth(.5))
		(rcap ParticipationEd_lo ParticipationEd_hi axis_3,
			lcolor(black))
		(bar ParticipationEnd axis_4, 
			color(gs10) barwidth(.5))
		(rcap ParticipationEnd_lo ParticipationEnd_hi axis_4,
			lcolor(black)),
legend(off)
ylabel(0(.1) .5)
title("Non-Electoral Participation Model")
ytitle("Pr(Participate)", size(medsmall))
xlabel(#3,valuelabel angle(horizontal))
name(GPH3, replace)
scheme(s1mono);
#delimit cr	


	    #delimit ;
		twoway (bar DiffTolerantState axis_1, color(black)) (rcap DiffTolerantState_hi DiffTolerantState_lo axis_1, color(gs10)) 
		(bar DiffHomophobicState axis_2, color(gs10)) (rcap DiffHomophobicState_hi DiffHomophobicState_lo axis_2, color(black)), 
		scheme(s1mono) ylabel(.05(.05) -.10) ytitle("Difference in Pr(Participate)", size(medsmall))
		yline(0)
		xlabel( 1 "Protecting" 2 "Persecuting", noticks) 
		name(GPH4, replace)  
		 legend(off)
		;
		#delimit cr
		

#delimit ;	
	graph combine GPH1 GPH3 GPH2 GPH4, rows(2) 
	title("Figure 1: Probability to vote and participate non-electorally by tolerance towards" 
	"gay people and LGBT rights (Protecting/Persecuting) with 95 percent confidence intervals", size(medium))
	note("Dependent variables: Participated(1), Didn't Participate(0). Results estimated with mixed effects" 
	"logit models while holding tolerance and LGBT+ rights (Protecting/Persecuting) at high and low" 
	"values, and holding control variables constant at mean and mode values. Data source:" "World Values Survey Waves 6 + 7 (2010-2020)", size(medsmall)) scheme(s1mono)
;
#delimit cr
		
		
		
		
		
		
		
		
		